<!DOCTYPE html>
<html lang="en" class="x-admin-sm" xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>关于信用守约明细</title>
    <header th:replace="header::html"></header>
    <link th:href="@{/xadmin/lib/layui/css/layui.css}" rel="stylesheet" type="text/css"/>
    <script th:src="@{/xadmin/lib/layui/layui.js}" type="text/javascript"></script>
</head>

<body>

    <div class="layui-fluid">
        <div class="layui-row  layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form  layui-col-space5">
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="startDate" placeholder="请选择开始日期"
                                           name="startDate">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="endDate" placeholder="请选择结束日期" name="endDate">
                                </div>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="search"><i
                                        class="layui-icon">&#xe615;</i></button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body ">
                        <table class="layui-hide" id="creditTable" lay-filter="creditTable" ></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script>

	layui.use('laydate', function () {
		var laydate = layui.laydate;
		//选中后的回调
		laydate.render({
			elem: '#startDate'
			, done: function (value, date) {
				// layer.alert('你选择的日期是：' + value + '<br>获得的对象是' + JSON.stringify(date));
			}
		});

		laydate.render({
			elem: '#endDate'
			, done: function (value, date) {
				// layer.alert('你选择的日期是：' + value + '<br>获得的对象是' + JSON.stringify(date));
			}
		});
	});


	layui.use(['table','form','layer'], function () {
		var table = layui.table,
            layer=layui.layer,
			form = layui.form;
		table.render({
			elem: '#creditTable'
			, url: '/api-front/credit/creditList' //数据接口
			, page: true //开启分页
			, cellMinWidth: 80 //全局定义常规单元格的最小宽度
			, limits:[10,20]
			,limit:10
			, response: {
				dataName: 'datas' //规定数据列表的字段名称，默认：data
			}
			, cols: [
				[
					{type:'numbers' ,align:'center'}
					,{field:'uaccount', title: '账号', width:'20%',align:'center'}
					,{field:'uname', width:'15%',align:'center',title: '姓名'}
					,{field:'scoredetails', align:'center', title: '流动明细',width: '30%'}
					,{field:'scoreflow', width:'8%',align:'center', title: '信用分流动'}
					,{field:'nowscore', width:'8%',align:'center', title: '当前信用分'}
					,{field:'ctime', align:'center', title: '时间',width: '15%',}
				]
			],
			done: function () {
				//checkPermission();
			}
		});

		//搜索
		form.on('submit(search)', function (data) {
			var field = data.field;
			if (dateCompare(field.startDate, field.endDate)) {
				table.render({
					elem: '#creditTable'
					, url: '/api-front/credit/creditList' //数据接口
					, page: true //开启分页
					, limits:[10,20]
                    ,limit:10
					, where: {
						"starttime": field.startDate,
						"endtime": field.endDate,
					}
					, response: {
						dataName: 'datas' //规定数据列表的字段名称，默认：data
					}
					, cols: [
						[
							{type:'numbers' ,align:'center'}
							,{field:'uaccount', title: '账号', width:'20%',align:'center'}
							,{field:'uname', width:'15%',align:'center',title: '姓名'}
							,{field:'scoredetails', align:'center', title: '流动明细',width: '30%'}
							,{field:'scoreflow', width:'8%',align:'center', title: '信用分流动'}
							,{field:'nowscore', width:'8%',align:'center', title: '当前信用分'}
							,{field:'ctime', align:'center', title: '时间',width: '15%',}
						]
					]
				});
			} else {
				layer.msg("您的日期不正确，请重新输入！",{icon:2});
			}
			return false;
		});
		//checkPermission();
	});

	function dateCompare(startDate, endDate) {
		var oDate1 = new Date(startDate);
		var oDate2 = new Date(endDate);
		if (oDate1 > oDate2) {
			return false;
		} else {
			return true;
		}
	}

</script>
</html>